package com.xzq.bizimpl;

import java.sql.Timestamp;
import java.util.Date;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.xzq.biz.ProductBiz;
import com.xzq.dao.ProductDao;
import com.xzq.entity.Page;
import com.xzq.entity.Product;
import com.xzq.entity.Type;
@Service
public class ProductBizImpl implements ProductBiz {
	@Resource
	private ProductDao dao;
	@Override
	public Page findAllProduct(Page page, Integer choose) {
		page = dao.findAllProduct(page, choose);
		return page;
	}

	@Override
	public Page findAllProductByType(Page page, Type type, Integer choose) {
		page = dao.findAllProductByType(page, type, choose);
		return page;
	}

	@Override
	public Page findLikeNameProduct(Page page, String likename, Integer choose) {
		page = dao.findLikeNameProduct(page, likename, choose);
		return page;
	}

	@Override
	public Product findOneProduct(Product product) {
		product = dao.findOneProduct(product);
		return product;
	}

	@Override
	public int addProduct(Product product) {
		Date d = new Date(System.currentTimeMillis());
		Timestamp ts = new Timestamp(d.getTime());
		product.setAddDate(ts);
		int count = dao.addProduct(product);
		return count;
	}

	@Override
	public int modifyProduct(Product product) {
		int count = dao.modifyProduct(product);
		return count;
	}

	@Override
	public int deleteProduct(Product product) {
		int count = dao.deleteProduct(product);
		return count;
	}

}
